package org.mule.transport.ftpext;

import org.mule.api.MuleEvent;
import org.mule.api.endpoint.OutboundEndpoint;
import org.mule.transport.ftp.FtpMessageDispatcher;

/**
 *
 * @author florin
 */
public class FtpExtMessageDispatcher extends FtpMessageDispatcher {

    FtpExtConnector extConnector;

    public FtpExtMessageDispatcher(OutboundEndpoint endpoint) {
        super(endpoint);
        extConnector = (FtpExtConnector) getConnector();

    }

    @Override
    protected void doDispatch(MuleEvent event) throws Exception {
        try {
            extConnector.acquireOutoundFtpConnectionPermit();
            super.doDispatch(event);
        } finally {
            extConnector.releaseOutoundFtpConnectionPermit();
        }
    }
}
